//
//  CylinderShape.h
//  Ray Tracer
//
//  Created by Kaila, Ashish on 3/24/13.
//  Copyright (c) 2013 Kaila, Ashish. All rights reserved.
//

#ifndef __Ray_Tracer__UnitCylinderShape__
#define __Ray_Tracer__UnitCylinderShape__

#include "scene_object.h"

// Unit cyclinder on xy plane with height on z axis
// The cylinder has its centre at origin and extends
// 1/2 unit above and below the z axis
class UnitCylinderShape : public SceneObject
{
public:
    
    UnitCylinderShape(Material* material);
    
    bool intersect(Ray3D& ray,
                   const Matrix4x4& worldToModel,
                   const Matrix4x4& modelToWorld) const;
    
    // Returns true if world point is contained within the object
    virtual bool contains(const Point3D& worldPoint, const Matrix4x4& worldToModel) const;
    
private:
    bool intersectWithCylinder(Ray3D& rayInObjectSpace) const;
    bool intersectWithCircles(Ray3D& rayInObjectSpace) const;
};

#endif /* defined(__Ray_Tracer__UnitCylinderShape__) */
